#include<iostream>
using namespace std;
const int N = 1e4 + 10;
int arr[N];
int n, s;
bool check(int x)
{
	int sum = 0;
	for (int i = 2; i <= 10; i++) {
		int k = 0;
		int z = x;
		bool flag = 1;
		while (z) {
			arr[k++] = z % i;
			z /= i;
		}
		for (int j = 0; j < k / 2; j++) {
			if (arr[j] != arr[k - j - 1]) {
				flag = 0;
			}
		}
		if (flag) {
			sum++;
			if (sum == 2) {
				return 1;
			}
		}
	}
	return 0;
}
int main()
{
	cin >> n >> s;
	int t = s;
	while (n--) {
		for (int i = t + 1;; i++) {
			if (check(i)) {
				cout << i << endl;
				t = i;
				break;
			}
		}
	}
	return 0;
}